public class z20175204 {
   public static void main(String args[]) {
      CargoBoat ship = new CargoBoat();
      ship.setMinContent(204);
      int m =204;
      try{  
           ship.loading(m);
           m = 20;
           ship.loading(m);
           m = 50;
           ship.loading(m);
           m = 100;
           ship.loading(m);
      }
      catch(DangerException2 e) {
           System.out.println(e.warnMess()); 
           System.out.println("min装载重量是"+m+"吨的集装箱\n");       
      }


      finally {
          System.out.printf("货船将正点启航");
      }
  }
}
class CargoBoat {
     int realContent;  //装载的重量
     int minContent;   
     public void setMinContent(int c) {
         minContent = c;
     }
     public void loading(int m) throws DangerException2 {
       realContent += m;
       if(realContent<minContent) {
          throw new DangerException2(); 
       }
       System.out.println("目前装载了"+realContent+"吨货物");
     }
}

class DangerException2 extends Exception {
   final String message = "超轻";
   public String warnMess() {
       return message;
   }
} 
